<%@ page language="java"  pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<style>
.pageFormContent p{width: 48%;}
.pageFormContent p label{width: 80px;}
span.error{left: 180px; width:100px; z-index:999;}
</style>
<script>
$(document).ready(function(){
  $("select[name='productId']").live("change",function(){ 
			var $this = $(this), brsel = $this.parent().parent().find("select[name=brandId]");
			if($this.val()== ""){
				$(brsel).children().not(":first").remove();
			}else{
				var txt = $("#span_am_json").text(), proId = $this.val();
				if($.trim(txt) != ""){
					$(brsel).children().not(":first").remove();
					var selJson = $.parseJSON(txt);
					$.each(selJson, function(i){
						var key2 = 'pro_'+proId;
						if(i == key2){ 
							$.each(selJson[i], function(j){
								$(brsel).append('<option value="'+selJson[i][j].id+'">'+selJson[i][j].brandName+'</option>');
							});
						}
					});
				}
			}
		});
});

function getPm(obj){
	var $this = $(obj);
	var modSel = $("select[name=modelId]");
	if($this.val()==""){
		$(modSel).children().not(":first").remove();
	}else{
	    var pmSel = $this.parent().parent().find("select[name=modelId]");
	    $(pmSel).children().not(":first").remove();
		$.post('getProModel', {"brandId": $this.val()}, 
			function(data) {
			if(data.result != ""){
				var pmJson = $.parseJSON(data.result);
				$.each(pmJson, function(i){
				   $(pmSel).append('<option value="'+pmJson[i].id+'">'+pmJson[i].modelName+'</option>');
				});
			}		 
		}, "json");
	}
}
</script>
<div class="pageContent">
	<form method="post" action="saveActivityModel?callbackType=closeCurrent" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone);">
		<div class="pageFormContent" layoutH="58">
			<p>
				<label>子活动ID：</label>
				<a class="btnLook" maxable="false" href="showSonActivity" lookupGroup="" rel="showSonActivity">查找带回</a>
				<input type="text" size="16" readonly="readonly" class="required" name="activtySonId" value=""  />
			</p>
			<p>
				<label>父活动ID：</label>
				<input type="text" readonly="readonly" name="activtyId" />
			</p>
			<div class="divider"></div>
			<div>
				<p>
					<label>品名：</label>
					<select name="productId" class="required" style="width: 133px;">
						<option value="">-选择品名-</option>
						<c:forEach var="pro" items="${productList}">
						<option value="${pro.id }">${pro.productName }</option>
						</c:forEach>
					</select>
				</p>
				<p>
					<label>品牌：</label>
					<select name="brandId" class="required" onchange="getPm(this);" style="width: 133px;">
						<option value="">-选择品牌-</option>
					</select>
				</p>
				<p>
					<label>型号：</label>
					<select name="modelId" class="required" style="width: 133px;">
						<option value="">-选择型号-</option>
					</select>
				</p>
				<p>
					<label>采购单价:</label>
					<input type="text" class="required number" name="purchasePrice" alt="请输入数字" />
				</p>
				<p>
					<label>补贴一:</label>
					<input type="text" class="required number" name="firstSubsidy" alt="请输入数字" />
				</p>
				<p>
					<label>补贴二:</label>
					<input type="text" class="required number" name="secondSubsidy" alt="请输入数字" />
				</p>
				<p>
					<label>补贴三:</label>
					<input type="text" class="required number" name="thirdSubsidy" alt="请输入数字" />
				</p>
				<p>
					<label>补贴四:</label>
					<input type="text" class="required number" name="fourthSubsidy" alt="请输入数字" />
				</p>
				<p>
					<label>补贴五:</label>
					<input type="text" class="required number" name="fifthSubsidy" alt="请输入数字" />
				</p>
				<p>
					<label>补贴六:</label>
					<input type="text" class="required number" name="sixthSubsidy" alt="请输入数字" />
				</p>
				
				<p>
					<label>备注：</label>
					<textarea rows="3" cols="19" name="mappDesc" maxlength="128"></textarea>
				</p>
			</div>
			 
		</div>
		<div class="formBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent">
				<button type="submit" >保存</button></div></div>
				<span style="display: none;" id="span_am_json">${brandOfProductJson }</span>
				<input type="hidden" value="0" id="divLen" />
				</li>
				<li>
					<div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
				</li>
			</ul>
		</div>
	</form>
</div>
